﻿<%@ Page Language="C#" %>

<%@ OutputCache Location="None" VaryByParam="None" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Globalization"%>
<%@ Import Namespace="System.Threading"%>
<%@ Import Namespace="System.Text.RegularExpressions"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // To convert the SQL Server versions to MS Access do the following:-
    //   Replace the 2 DSN lines
    //   Replace all code of:-   SQLCommand   to   OleDbCommand
    //   Replace all code of:-   SQLDatareader   to   OleDbDatareader
    //   Replace Dates from '  to #  (do not need ' for SQL Server)   (eg strStartDate = "#" & strStartDate & "#")
    //   Change Function DateConvitfromformUS, also  (see comments in Function itself)
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    long intSkipCount;
    long intTotalPages;
    long intPageSize;
    long intCurrentPage;
    long intTotalNoRecords;
    long intRowID;
    string strSortField;
    string strInnerAction;
    string strAction;
    string strpageload;
    string strDispTotals;
    string strDispPageCounts;
    string strDispPKID;
    string strDispPKIDNEW;
    string strDataTable;
    string strHeaderTable;
    string strNavTable;
    string strbtnLastPage;
    string strbtnFirstPage;
    string strbtnPreviousPage;
    string strbtnNextPage;
    string strlblCurrentPage;
    string strarraysearch;
    string strmachsearch;
    string strPKID;
    string strPKIDNEW;
    string strDispSEARCH;
    string strchkresetcriteria;
    string strarraysearch2;
    string strDoSort;
    string strSortDirection;
    string strDispSortDirection;
    
    //NET 1.1
    //SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["DSN"]);
    //NET 2.0
    SqlConnection objConn = new SqlConnection(ConfigurationManager.AppSettings["DSN"]);

    //=======================================================================================
    // NOTE:-
    // Code that can be Customised are marked by &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
    //
    //=======================================================================================


    void Page_Load()
    {
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Change records per page to suit
        intPageSize = 8;          //can be changed to suit what is required
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        strAction = Request.QueryString["action"];             //get action from another web page

        strDoSort = Request.QueryString["dosort"];        //check whether clicked on a sort column

        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Add Search criteria, or comment out if not using search criteria (can leave in)
        strarraysearch = Request.QueryString["textsearch"];
        if (strarraysearch == null
            || strarraysearch.Length == 0)
        {
            //nothing
        }
        else
        {
            strarraysearch = strarraysearch.Replace("'", "''");                     //so as to cope with any Apostrophes in text
        }

        strmachsearch = Request.QueryString["dropdownsearch"];
        if (strmachsearch == null
            || strmachsearch.Length == 0)
        {
            //nothing
        }
        else
        {
            strmachsearch = strmachsearch.Replace("'", "''");                     //so as to cope with any Apostrophes in text
        }
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //Get Total Page count and Total Record count, to store hidden on Page
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        intTotalNoRecords = Get_Total_Records();

        intTotalPages = (intTotalNoRecords / intPageSize);
        //Adjust the page count if the last page contains a partial page.
        if ((intTotalNoRecords % intPageSize) > 0)
        {
            intTotalPages = (intTotalPages + 1);
        }

        //STORE Total HIDDEN values ready to display
        strDispTotals = DispTotalInfo(intTotalPages, intTotalNoRecords);
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //END Get Total Page count and Total Record count
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


        if ((intTotalNoRecords > 0))
        {
            switch (strAction)
            {
                case "firstpage":
                    intCurrentPage = Convert.ToInt64(Request.QueryString["pageid"]);
                    intRowID = 0;
                    intSkipCount = 0;
                    strSortField = Request.QueryString["sortby"];
                 
                    //        strSortField = Regex.Replace(strSortField, "asc", "desc");
                  
                    //Response.Write("strSortField is " + strSortField);
                    // STORE Page Counts HIDDEN values ready to display
                    strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                    DisplayFirstPage();
                    break;
                case "nextpage":
                    if (((intCurrentPage == intTotalPages)
                                || (Convert.ToInt64(Request.QueryString["pageid"]) == intTotalPages)))
                    {
                        intRowID = 0;
                        intSkipCount = ((intTotalPages - 1) * intPageSize);
                        intCurrentPage = intTotalPages;
                        strSortField = Request.QueryString["sortby"];
                        // Sorting by   
                        // STORE Page Counts HIDDEN values ready to display
                        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                        NextPage();
                    }
                    else
                    {
                        intCurrentPage = (Convert.ToInt64(Request.QueryString["pageid"]) + 1);
                        intRowID = 0;
                        strSortField = Request.QueryString["sortby"];
                        // Workout SkipCount of records, for next page
                        intSkipCount = (Convert.ToInt64(Request.QueryString["skip"]) + intPageSize);
                        // STORE Page Counts HIDDEN values ready to display
                        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                        NextPage();
                    }
                    break;
                case "prevpage":
                    if (((intCurrentPage == 1)
                                || (Convert.ToInt64(Request.QueryString["pageid"]) == 1)))
                    {
                        intRowID = 0;
                        intSkipCount = 0;
                        intCurrentPage = 1;
                        strSortField = Request.QueryString["sortby"];
                        // STORE Page Counts HIDDEN values ready to display
                        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                        DisplayFirstPage();
                    }
                    else
                    {
                        intCurrentPage = (Convert.ToInt64(Request.QueryString["pageid"]) - 1);
                        intRowID = 0;
                        strSortField = Request.QueryString["sortby"];
                        intSkipCount = (int.Parse(Request.QueryString["skip"]) - intPageSize);
                        // STORE Page Counts HIDDEN values ready to display
                        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                        PrevPage();
                    }
                    break;
                case "lastpage":
                    if (((intCurrentPage == intTotalPages)
                                || (Convert.ToInt64(Request.QueryString["pageid"]) == intTotalPages)))
                    {
                        intRowID = 0;
                        intSkipCount = ((intTotalPages - 1) * intPageSize);
                        intCurrentPage = intTotalPages;
                        strSortField = Request.QueryString["sortby"];
                        // STORE Page Counts HIDDEN values ready to display
                        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                        NextPage();
                        // If cint(Request.QueryString("pageid")) = intTotalPages then  'old code for non image buttons
                        // nothing
                    }
                    else
                    {
                        intCurrentPage = intTotalPages;
                        intRowID = 0;
                        strSortField = Request.QueryString["sortby"];
                        intSkipCount = ((intTotalPages - 1) * intPageSize);
                        // STORE Page Counts HIDDEN values ready to display
                        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                        NextPage();
                    }
                    break;
                case "pageid":
                    intCurrentPage = Convert.ToInt64(Request.QueryString["pageid"]);
                    intRowID = 0;
                    strSortField = Request.QueryString["sortby"];
                    intSkipCount = ((intCurrentPage * intPageSize) - intPageSize);
                    // STORE Page Counts HIDDEN values ready to display
                    strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                    NextPage();
                    break;
                case "GetCurrentPage":
                    strchkresetcriteria = Request.QueryString["chkresetcriteria"];
                    // use to check if Search Criteria field have changed
                    strPKIDNEW = Request.QueryString["num"];
                    intCurrentPage = Convert.ToInt64(Request.QueryString["pageid"]);
                    intRowID = Convert.ToInt64(Request.QueryString["rowid"]);
                    strSortField = Request.QueryString["sortby"];
                    intSkipCount = Convert.ToInt64(Request.QueryString["skip"]);
                    strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                    NextPage();
                    strDispPKID = DispPKIDInfo(strPKIDNEW);
                    break;
                default:
                    intSkipCount = 0;
                    intCurrentPage = 1;
                    intRowID = 0;
                    // STORE Page Counts HIDDEN values ready to display
                    strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
                    DisplayFirstPage();
                    break;
            }

            // DISPLAY OUTPUT to go BACK (to innerHTML of Requested Page)
            Response.Write(strHeaderTable);
            Response.Write(strDataTable);
            Response.Write(strNavTable);
            Response.Write(strDispPKID);
            strDispSEARCH = DispSEARCHInfo(strchkresetcriteria);
            Response.Write(strDispSEARCH);
            Response.Write(strDispPageCounts);
            Response.Write(strDispTotals);
            //Response.Write(strDispSortDirection);
            Response.End();

            // *************************************************************************************************************************************************************
            // This next Part is for writing out to a HTML page so as to see Layout Design
            // USED ONLY FOR TESTING
            //string FILENAME = Server.MapPath("Output.html");
            //StreamWriter objStreamWriter;
            //objStreamWriter = File.AppendText(FILENAME);
            //objStreamWriter.WriteLine(strNavTable);
            //objStreamWriter.WriteLine(strHeaderTable);
            //objStreamWriter.WriteLine(strDataTable);
            //objStreamWriter.Close();
            // *************************************************************************************************************************************************************
        }
        else
        {
            // No records found
            intSkipCount = 0;
            intCurrentPage = 1;
            intRowID = 0;
            strNavTable = "";
            strHeaderTable = "";
            GetHeaderTable();
            strDataTable = "";
            strDispPKID = "";
            strDispSEARCH = "";
            strDispPageCounts = "";
            strDispTotals = "";

            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Change next line to Sort default as in ARRAYS_LIST.aspx
            strSortField = "PK_ID";
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

            strchkresetcriteria = "No Records";
            strDispSEARCH = DispSEARCHInfo(strchkresetcriteria);
            strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);
            strPKIDNEW = "0";
            strDispPKID = DispPKIDInfo(strPKIDNEW);
            Response.Write(strDispPageCounts);
            Response.Write(strDispTotals);
            Response.Write(strDispSortDirection);
            Response.Write(strDispSEARCH);
            // Response.Write(strHeaderTable)    'Optional taking out Header display
            Response.Write(strDispPKID);
            Response.End();
        }
        // If intTotalNoRecords > 0

    }



    //--------------------------------------------------------------------------------------------------------------------------------------------------------------
    //These next 5 Functions are used to keep internal variables, and so are MANDATORY
    // NOTE:-  Can change type=hidden  -->   type=text, for displaying variables below
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------
    string DispTotalInfo(long TotalPages, long TotalNoRecords)
    {
        string cRet;
        cRet = "";
        cRet = cRet + "<input name='TotalPages' id='TotalPages' type='hidden' value='" + TotalPages + "' />" + "\r\n";      //\r\n is vbCrLf in VB
        cRet = cRet + "<input name='TotalNoRecords' id='TotalNoRecords' type='hidden' value='" + TotalNoRecords + "' />" + "\r\n";
        return cRet;
    }

    string DispPageCountInfo(long PageSize, long CurrentPage, long RowID, long SkipCount, string SortField)
    {
        string cRet;
        cRet = "";
        cRet = (cRet + ("<input name='CurrentPageGet' id='CurrentPageGet' type='hidden' value='" + (CurrentPage + ("' />" + "\r\n"))));
        cRet = (cRet + ("<input name='RowIDGet' id='RowIDGet' type='hidden' value='" + (RowID + ("' />" + "\r\n"))));
        cRet = (cRet + ("<input name='SkipCount' id='SkipCount' type='hidden' value='" + (SkipCount + ("' />" + "\r\n"))));
        cRet = (cRet + ("<input name='PageSizeGet' id='PageSizeGet' type='hidden' value='" + (PageSize + ("' />" + "\r\n"))));
        cRet = (cRet + ("<input name='SortFieldGet' id='SortFieldGet' type='text' value='" + (SortField + ("' />" + "\r\n"))));
        return cRet;
    }

    string DispPKIDInfo(string PKID)
    {
        string cRet;
        cRet = "";
        cRet = (cRet + ("<input name='textcurrentpkid' id='textcurrentpkid' type='hidden' value='"
                    + (PKID + ("' />" + "\r\n"))));
        return cRet;
    }

    string DispSEARCHInfo(string chkresetcriteria)
    {
        string cRet;
        cRet = "";
        cRet = (cRet + ("<input name='chkresetcriteria' id='chkresetcriteria' type='hidden' value='"
                    + (chkresetcriteria + ("' />" + "\r\n"))));
        return cRet;
    }
    
    //string DispPageSortDir(string SortDirection)
    //{
    //    string cRet;
    //    cRet = "";
    //    cRet = (cRet + ("<input name='SortDirectionGet' id='SortDirectionGet' type='text' value='" + (SortDirection + ("' />" + "\r\n"))));
    //    return cRet;
    // }
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------
    // END of 5 Functions are used to keep internal variables, and so are MANDATORY
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------



    long Get_Total_Records()
    {
        // ------------------------------------------------------------------------------------------- 
        int intwherecounter;
        long intCounter;
        SqlCommand objCmd;
        string strSQL;

        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        strSQL = "SELECT count(PK_ID) from ARRAYS2 ";
        intwherecounter = 0;
        if (strarraysearch == null
                    || (strarraysearch.Length == 0))
        {
            // nothing to Search
        }
        else
        {
            // NOTE:- To make faster, put % only at end
            strSQL = (strSQL + (" WHERE Array_Name like \'%"
                        + (strarraysearch + "%\'")));
            intwherecounter = 1;
        }
        if (strmachsearch == null
                    || (strmachsearch.Length == 0))
        {
            // nothing to Search
        }
        else if ((intwherecounter == 1))
        {
            strSQL = (strSQL + (" AND ~dropdownsearch~ = \'"
                        + (strmachsearch + "\'")));
        }
        else
        {
            strSQL = (strSQL + (" WHERE ~dropdownsearch~ = \'"
                        + (strmachsearch + "\'")));
        }
        // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

        objCmd = new SqlCommand(strSQL, objConn);
        objConn.Open();
        intCounter = 0;
        intCounter = Convert.ToInt64(objCmd.ExecuteScalar());
        objConn.Close();

        return intCounter;

    }



    void DisplayFirstPage()
    {
        // ------------------------------------------------------------------------------------------- 
        // response.write("in First Page & "<br>"")
        // STORE Page Counts HIDDEN values ready to display
        strDispPageCounts = DispPageCountInfo(intPageSize, intCurrentPage, intRowID, intSkipCount, strSortField);

        GetPageOfRecords();          // global subroutine
        GetHeaderTable();

        //strbtnPreviousPage = "disabled='disabled'";
        //strbtnFirstPage = "disabled='disabled'";
        strbtnPreviousPage = "hidden";
        strbtnFirstPage = "hidden";
        strbtnNextPage = "";
        strbtnLastPage = "";

        DisplayPageInfo();               // global subroutine
        GetNavigationTable();
    }


    void NextPage()
    {
        // ------------------------------------------------------------------------------------------- 
        // response.write("in Next Page & "<br>"")
        // Check if on First Page
        if ((intCurrentPage == 1))
        {
            // at first page
            DisplayFirstPage();
            return;
        }
        GetPageOfRecords();
        // global subroutine
        GetHeaderTable();
        if ((intCurrentPage == intTotalPages))
        {
            // at last page
            strbtnNextPage = "hidden";
            strbtnLastPage = "hidden";
            strbtnPreviousPage = "";
            strbtnFirstPage = "";
        }
        else
        {
            strbtnNextPage = "";
            strbtnLastPage = "";
            strbtnPreviousPage = "";
            strbtnFirstPage = "";
        }
        DisplayPageInfo();

        // global subroutine
        GetNavigationTable();
    }


    void PrevPage()
    {
        // ------------------------------------------------------------------------------------------- 
        // response.write("in Previous Page & "<br>"")
        // Check if on First Page
        if ((intCurrentPage == 1))
        {
            // at first page
            DisplayFirstPage();
            return;
        }

        GetPageOfRecords();
        // global subroutine
        GetHeaderTable();

        strbtnPreviousPage = "";
        strbtnFirstPage = "";
        strbtnNextPage = "";
        strbtnLastPage = "";
        DisplayPageInfo();
        // global subroutine
        GetNavigationTable();
    }


    // --------------------------------------------------------------------------------------------------------------------------------------------------------------
    private void DisplayPageInfo()
    {
        //  This displays (eg Page 1 of 23     Total Records:  457)  on top of navigation buttons
        //  Can be modified to suit
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------
        if (((intTotalPages == 1)
                    || (intTotalPages == 0)))
        {
            strbtnNextPage = "hidden";
            strbtnLastPage = "hidden";
            strbtnPreviousPage = "hidden";
            strbtnFirstPage = "hidden";
        }

        strlblCurrentPage = "";
        strlblCurrentPage = "Page: " + Convert.ToString(intCurrentPage) + "  of  " + Convert.ToString(intTotalPages) +
                              "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
                              "" + Convert.ToString(intTotalNoRecords) + " Records"; ;

    }



    // --------------------------------------------------------------------------------------------------------------------------------------------------------------
    private void GetNavigationTable()
    {
        //  This displays navigation buttons (ie First Page, Next, Prev, Last Page)
        //  Can be modified to suit
        // -------------------------------------------------------------------------------------------------------------------------------------------------------------
        //Response.Write(("in GetNavigationTable " + "<br>\""));
        int intPageCnt;
        strNavTable = "";

        strNavTable = (strNavTable + ("<div" + "\r\n"));
        strNavTable = (strNavTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
        strNavTable = (strNavTable + (" BORDER-BOTTOM: 1px solid white;" + "\r\n"));
        strNavTable = (strNavTable + (" BORDER-LEFT: 1px solid white;" + "\r\n"));
        strNavTable = (strNavTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
        strNavTable = (strNavTable + ("</div>" + "\r\n"));

        strNavTable = (strNavTable + ("<table id='myNav' border='0' bgcolor='#006699' bordercolor='gray' cellspacing='0' cellpadding='0'  width='682" + "px'>" + "\r\n"));
        //strNavTable = (strNavTable + ("<tr>" + "\r\n"));
        //strNavTable = (strNavTable + ("<td>" + "\r\n"));
        // strNavTable = (strNavTable + (" " + "\r\n"));
        //strNavTable = (strNavTable + ("</td>" + "\r\n"));
        //strNavTable = (strNavTable + ("</tr>" + "\r\n"));
        //strNavTable = (strNavTable + ("<tr>" + "\r\n"));
        //strNavTable = (strNavTable + ("<td>" + "\r\n"));
        //strNavTable = (strNavTable + ("<span id=\'lblMessage\' tabindex=\'-1\'></span>" + "\r\n"));
        //strNavTable = (strNavTable + ("</td>" + "\r\n"));
        //strNavTable = (strNavTable + ("</tr>" + "\r\n"));
        strNavTable = (strNavTable + ("<tr>" + "\r\n"));
        strNavTable = (strNavTable + ("<td width='240px' " + "\r\n"));
        strNavTable = (strNavTable + (" style='FONT-SIZE: 12px;" + "\r\n"));
        strNavTable = (strNavTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strNavTable = (strNavTable + (" COLOR: white;" + "\r\n"));
        strNavTable = (strNavTable + (" PADDING: 2px';" + "\r\n"));
        strNavTable = (strNavTable + (" BORDER-RIGHT: 1px solid gray'>" + "\r\n"));
        
        strNavTable = (strNavTable + ("<span id='lblCurrentPage' tabindex='-1'>" + (strlblCurrentPage + ("</span>" + "\r\n"))));
        strNavTable = (strNavTable + ("</td>" + "\r\n"));
        strNavTable = (strNavTable + ("<td align='right' width=10px" + "\r\n"));
        strNavTable = (strNavTable + (" style='FONT-SIZE: 12px;" + "\r\n"));
        strNavTable = (strNavTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strNavTable = (strNavTable + (" COLOR: white;" + "\r\n"));
        strNavTable = (strNavTable + (" PADDING: 0px'>" + "\r\n"));
        
        // ............................................................................................................................................................................................................................................
        // FIRST PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //strNavTable = (strNavTable + ("<input type=\'submit\' name=\'btnFirstPage\' value=\'<<\' id=\'btnFirstPage\' " + (strbtnFirstPage + (" tabindex=\'-1\' " + "\r\n"))));
        //strNavTable = (strNavTable + (" onclick=\'javascript: initload(" + ('"' + (strSortField + ('"' + (");return false;\' " + (" />" + "\r\n")))))));
        if (strbtnFirstPage != "hidden")
        {
            strNavTable = (strNavTable + ("<a id='navigat' href='javascript: FirstPageit(" + ('"' + (strSortField + ('"' + (");'>" + "\r\n"))))));
            //strNavTable = (strNavTable + (" <img SRC=\'images/FIRST_09.gif\' ALT=\'First Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'22\' HEIGHT=\'20\' border=\'0\'>" + "\r\n"));
            // strNavTable = (strNavTable + (" <img SRC=\'images/FIRST_10.gif\' ALT=\'First Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'23\' HEIGHT=\'25\' border=\'0\'>" + "\r\n"));
            strNavTable = (strNavTable + (" << " + "\r\n"));

            strNavTable = (strNavTable + (" </a>" + " " + "\r\n"));
        }
        
        strNavTable = (strNavTable + ("</td>" + "\r\n"));
        strNavTable = (strNavTable + ("<td width=16px" + "\r\n"));
        strNavTable = (strNavTable + (" style='FONT-SIZE: 12px;" + "\r\n"));
        strNavTable = (strNavTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strNavTable = (strNavTable + (" COLOR: white;" + "\r\n"));
        strNavTable = (strNavTable + (" PADDING: 0px'>" + "\r\n"));
        
        // ............................................................................................................................................................................................................................................
        // PREVIOUS PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //strNavTable = (strNavTable + ("<input type=\'submit\' name=\'btnPreviousPage\' value=\'<\' id=\'btnPreviousPage\' " + (strbtnPreviousPage + (" tabindex=\'-1\' " + "\r\n"))));
        //strNavTable = (strNavTable + (" onclick=\'javascript: PrevPageit(" + ('"' + (intCurrentPage + ('"' + ",")))));
        //strNavTable = (strNavTable + ('"' + (strSortField + ('"' + ","))));
        //strNavTable = (strNavTable + ('"' + (intSkipCount + ('"' + (");return false;\' " + (" />" + "\r\n"))))));
        if (strbtnPreviousPage != "hidden")
        {
            strNavTable = (strNavTable + ("<a id='navigat' href='javascript: PrevPageit(" + ('"' + (intCurrentPage + ('"' + ",")))));
            strNavTable = (strNavTable + ('"' + (strSortField + ('"' + ","))));
            strNavTable = (strNavTable + ('"' + (intSkipCount + ('"' + (");\' " + (" >" + "\r\n"))))));
            //strNavTable = (strNavTable + (" <img SRC=\'images/PREV_09.gif\' ALT=\'Previous Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'17\' HEIGHT=\'20\' border=\'0\'>" + "\r\n"));
            //strNavTable = (strNavTable + (" <img SRC=\'images/PREV_10.gif\' ALT=\'Previous Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'15\' HEIGHT=\'25\' border=\'0\'>" + "\r\n"));
            strNavTable = (strNavTable + (" Prev " + "\r\n"));
            strNavTable = (strNavTable + (" </a>" + " " + "\r\n"));
        }
        
        strNavTable = (strNavTable + ("</td>" + "\r\n"));
        strNavTable = (strNavTable + ("<td width=16px" + "\r\n"));
        strNavTable = (strNavTable + (" style='FONT-SIZE: 12px;" + "\r\n"));
        strNavTable = (strNavTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strNavTable = (strNavTable + (" COLOR: white;" + "\r\n"));
        strNavTable = (strNavTable + (" PADDING: 0px'>" + "\r\n"));
        
        // ............................................................................................................................................................................................................................................
        // NEXT PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //strNavTable = (strNavTable + ("<input type=\'submit\' name=\'btnNextPage\' value=\'>\' id=\'btnNextPage\' " + (strbtnNextPage + (" tabindex=\'-1\' " + "\r\n"))));
        //strNavTable = (strNavTable + (" onclick=\'javascript: NextPageit(" + ('"' + (intCurrentPage + ('"' + ",")))));
        //strNavTable = (strNavTable + ('"' + (strSortField + ('"' + ","))));
        //strNavTable = (strNavTable + ('"' + (intSkipCount + ('"' + (");return false;\' " + (" />" + "\r\n"))))));
        if (strbtnNextPage != "hidden")
        {
            strNavTable = (strNavTable + ("<a id='navigat' href='javascript: NextPageit(" + ('"' + (intCurrentPage + ('"' + ",")))));
            strNavTable = (strNavTable + ('"' + (strSortField + ('"' + ","))));
            strNavTable = (strNavTable + ('"' + (intSkipCount + ('"' + (");\' " + (" >" + "\r\n"))))));
            //strNavTable = (strNavTable + (" <img SRC=\'images/NEXT_09.gif\' ALT=\'Next Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'17\' HEIGHT=\'20\' border=\'0\'>" + "\r\n"));
            //strNavTable = (strNavTable + (" <img SRC=\'images/NEXT_10.gif\' ALT=\'Next Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'15\' HEIGHT=\'25\' border=\'0\'>" + "\r\n"));
            strNavTable = (strNavTable + (" Next " + "\r\n"));
            strNavTable = (strNavTable + (" </a>" + " " + "\r\n"));
        }
        
        strNavTable = (strNavTable + ("</td>" + "\r\n"));
        strNavTable = (strNavTable + ("<td width=1px" + "\r\n"));
        strNavTable = (strNavTable + (" style='FONT-SIZE: 12px;" + "\r\n"));
        strNavTable = (strNavTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strNavTable = (strNavTable + (" COLOR: white;" + "\r\n"));
        strNavTable = (strNavTable + (" PADDING: 0px'>" + "\r\n"));
        
        // ............................................................................................................................................................................................................................................
        // LAST PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //strNavTable = (strNavTable + ("<input type=\'submit\' name=\'btnLastPage\' value=\'>>\' id=\'btnLastPage\' " + (strbtnLastPage + (" tabindex=\'-1\' " + "\r\n"))));
        //strNavTable = (strNavTable + (" onclick=\'javascript: LastPageit(" + ('"' + (intCurrentPage + ('"' + ",")))));
        //strNavTable = (strNavTable + ('"' + (strSortField + ('"' + ","))));
        //strNavTable = (strNavTable + ('"' + (intSkipCount + ('"' + (");return false;\' " + (" />" + "\r\n"))))));
        if (strbtnLastPage != "hidden")
        {
            strNavTable = (strNavTable + ("<a id='navigat' href='javascript: LastPageit(" + ('"' + (intCurrentPage + ('"' + ",")))));
            strNavTable = (strNavTable + ('"' + (strSortField + ('"' + ","))));
            strNavTable = (strNavTable + ('"' + (intSkipCount + ('"' + (");\' " + (" >" + "\r\n"))))));
            //strNavTable = (strNavTable + (" <img SRC=\'images/LAST_09.gif\' ALT=\'Last Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'21\' HEIGHT=\'20\' border=\'0\'>" + "\r\n"));
            //strNavTable = (strNavTable + (" <img SRC=\'images/LAST_10.gif\' ALT=\'Last Page\' " + "\r\n"));
            //strNavTable = (strNavTable + ("  WIDTH=\'23\' HEIGHT=\'25\' border=\'0\'>" + "\r\n"));
            strNavTable = (strNavTable + (" >> " + "\r\n"));
            strNavTable = (strNavTable + (" </a> " + "\r\n"));
        }

        strNavTable = (strNavTable + ("</td>" + "\r\n"));
        strNavTable = (strNavTable + ("<td width=282px" + "\r\n"));
        strNavTable = (strNavTable + (" style='FONT-SIZE: 12px;" + "\r\n"));
        strNavTable = (strNavTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strNavTable = (strNavTable + (" COLOR: white;" + "\r\n"));
        strNavTable = (strNavTable + (" PADDING: 0px'>" + "\r\n"));
        
        
        
        for (intPageCnt = 1; (intPageCnt <= intTotalPages); intPageCnt++)
        {
            if ((intPageCnt == 1))
            {
                //strNavTable = (strNavTable + (" " + ("<a id=\'LinkButton1\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("1" + ('"' + ("," + ('"' 
                //            + (strSortField + ('"' + (")\'>1</a> " + " ")))))))))));
            }
            if ((intPageCnt == 2))
            {
                //strNavTable = (strNavTable + ("<a id=\'LinkButton2\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("2" + ('"' + ("," + ('"' 
                //            + (strSortField + ('"' + (")\'>2</a> " + " "))))))))));
            }
            if ((intPageCnt == 3))
            {
                //strNavTable = (strNavTable + ("<a id=\'LinkButton3\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("3" + ('"' + ("," + ('"' 
                //            + (strSortField + ('"' + (")\'>3</a> " + " "))))))))));
            }
            if ((intPageCnt == 4))
            {
                // strNavTable = (strNavTable + ("<a id=\'LinkButton4\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("4" + ('"' + ("," + ('"' 
                //              + (strSortField + ('"' + (")\'>4</a> " + " "))))))))));
            }
            if ((intPageCnt == 5))
            {
                // strNavTable = (strNavTable + ("<a id=\'LinkButton3\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("5" + ('"' + ("," + ('"' 
                //          + (strSortField + ('"' + (")\'>5</a> " + " "))))))))));
            }
            if ((intPageCnt == 6))
            {
                // strNavTable = (strNavTable + ("<a id=\'LinkButton4\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("6" + ('"' + ("," + ('"' 
                //           + (strSortField + ('"' + (")\'>6</a> " + " "))))))))));
            }
        }


        //strNavTable = (strNavTable + ("<a id=\'LinkButton1\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("1" + ('"' + ("," + ('"' + (strSortField + ('"' + (")\'>1</a> " + " "))))))))));
        //strNavTable = (strNavTable + ("<a id=\'LinkButton2\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("2" + ('"' + ("," + ('"' + (strSortField + ('"' + (")\'>2</a> " + " "))))))))));
        //strNavTable = (strNavTable + ("<a id=\'LinkButton3\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("3" + ('"' + ("," + ('"' + (strSortField + ('"' + (")\'>3</a> " + " "))))))))));
        //strNavTable = (strNavTable + ("<a id=\'LinkButton4\' tabindex=\'-1\' href=\'javascript:PageID(" + ('"' + ("4" + ('"' + ("," + ('"' + (strSortField + ('"' + (")\'>4</a> " + " "))))))))));

        strNavTable = (strNavTable + ("</td>" + "\r\n"));
        strNavTable = (strNavTable + ("</tr>" + "\r\n"));
        strNavTable = (strNavTable + ("</table>" + "\r\n"));
    }




    void GetPageOfRecords()
    {
        //response.write(("in GetPageOfRecords " + "<br>\""));
        long intcounter;
        long intwherecounter;
        long introwcounter;
        long intsubcounter;
        SqlCommand objCmd;
        SqlDataReader objDR;
        string strSQL;
        string strBoolean;
        string strStartDate;
        string strEndDate;
        string strFlag;
        string strsize2;
        string strdatename;
        string strPK;
        string strsort;
        string strFields;
        string strfiltercheck;
        string strfilter;
        string strsimplefilter;
        string strTable;
        string ws_conv_datestring;
        DateTime ws_conv_date;


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        strTable = "ARRAYS2";
        strPK = "PK_ID";
        //strsort = "";

        strsort = " ORDER BY " + strSortField + " ";
        strFields = "PK_ID, Array_Name, Loaded_Machine, Complete_Flag, Start_Date, End_Date";

        strfiltercheck = "";
        intwherecounter = 0;

        //Add Search criteria, or take out if not using search criteria
        //-----------------------------------------------------------------------------------
        if (strarraysearch == null
          || strarraysearch.Length == 0)
        {
            //nothing to Search
        }
        else
        {
            //NOTE:- To make faster, put % only at end
            strfiltercheck = strfiltercheck + " Array_Name like '%" + strarraysearch + "%'";
            intwherecounter = 1;
        }

        if (strmachsearch == null
           || strmachsearch.Length == 0)
        {
            //nothing to Search
        }
        else
        {
            if (intwherecounter == 1)
            {
                strfiltercheck = strfiltercheck + " AND ~dropdownsearch~ = '" + strmachsearch + "'";
            }
            else
            {
                strfiltercheck = strfiltercheck + " ~dropdownsearch~ = '" + strmachsearch + "'";
            }
        }
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        if (strfiltercheck == "")
        {
            strfilter = "";
            strsimplefilter = "";
        }
        else
        {
            strfilter = " WHERE " + strfiltercheck;
            strsimplefilter = " AND " + strfiltercheck;
        }


        //Check if on First Page, to determine what Query to use
        if (intCurrentPage == 1)      //at first page
        {
            strSQL = "SELECT TOP " + intPageSize + " " + strFields + " FROM " + strTable
               + strfilter + strsort;
        }
        else
        {
            strSQL = "SELECT TOP " + intPageSize + " " + strFields + " FROM " + strTable
             + " WHERE " + strPK + " NOT IN "
             + " (SELECT TOP " + intSkipCount + " " + strPK + " FROM " + strTable
             + " " + strfilter + strsort + ") "
             + strsimplefilter + strsort;

        }

        //Next lines are used for Testing
        //Response.Write(("strSQL is " + strSQL + "<br>\""));
        //if (intCurrentPage > 1)
        //{
        //break;
        //}


        objCmd = new SqlCommand(strSQL, objConn);

        objConn.Open();
        objDR = objCmd.ExecuteReader();

        strDataTable = "";

        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Must change Table width to suit Columns (always make a longer than actual calculation)
        //----------------------------------------------------------------------------------------------------------
        strDataTable = ((strDataTable + "<table id='myTable' border='0' bgcolor='white' bordercolor='gray' cellspacing='0' cellpadding='0'  width='682" + "px'>") + "\r\n");
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

        intcounter = 0;
        introwcounter = 0;
        intsubcounter = 0;

        while (objDR.Read())
        {

            //Setup ROW
            strDataTable = (strDataTable + ("<tr>" + "\r\n"));


            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //NOTE:- OPTIONAL - Can use hypertext on other columns instead (Also must adjust Table width size again)
            //DETAIL Column, PK_ID may have to change
            //-----------------------------------------------------
            //strDataTable = strDataTable & "<td ALIGN=center WIDTH=17px HEIGHT=21px" & vbCRLF
            //strDataTable = strDataTable & " style='BORDER-TOP: 1px solid black;" & vbCRLF
            //strDataTable = strDataTable & " BORDER-BOTTOM: 1px solid black;" & vbCRLF
            //strDataTable = strDataTable & " BORDER-LEFT: 1px solid black;" & vbCRLF
            //strDataTable = strDataTable & " BORDER-RIGHT: 1px solid black'>" & vbCRLF
            //strDataTable = strDataTable & "<a href='JavaScript: Detail1(" & chr(34) & objDR.Item("PK_ID") & chr(34) & "," & chr(34) & intcounter & chr(34) &  "," 
            //strDataTable = strDataTable & chr(34) & intCurrentPage & chr(34) & "," & chr(34) & intSkipCount & chr(34) & "," 
            //strDataTable = strDataTable & chr(34) & strSortField & chr(34) & "," & chr(34) & intPageSize & chr(34) & ")' " & " tabIndex='-1' title='Title' " &  " >" & vbCRLF
            //     strDataTable = strDataTable & " <img SRC='./images/DETAIL_04.gif' ALT='Array Details' TITLE='Array Details' WIDTH=50px HEIGHT=21px border='0'> " & vbCRLF
            //strDataTable = strDataTable & " <img SRC='./images/DETAIL_08.bmp' ALT='Array Details' TITLE='Array Details' WIDTH=8px HEIGHT=13px border='0'> " & vbCRLF
            //strDataTable = strDataTable & "</a>" & vbCRLF
            //strDataTable = strDataTable & "</td>" & vbCRLF

            strDataTable = (strDataTable + ("<td ALIGN='center' WIDTH='45px' HEIGHT='21px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-SIZE: 11px;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-FAMILY: Arial;" + "\r\n"));
            strDataTable = (strDataTable + (" COLOR: navy;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
            strDataTable = (strDataTable + ("<a href='JavaScript: Detail1(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex=\'-1\' title=\'Title\' " + (" >" + "\r\n")))))))))));
            //strDataTable = (strDataTable + (" <img SRC=\'./images/DETAIL_04.gif\' ALT=\'Array Details\' TITLE=\'Array Details\' WIDTH=50px HEIGHT=21px b" +"order=\'0\'> " + "\r\n"));
            //strDataTable = (strDataTable + (" <img SRC=\'./images/DETAIL_08.bmp\' ALT=\'Array Details\' TITLE=\'Array Details\' WIDTH=8px HEIGHT=13px bo" +"rder=\'0\'> " + "\r\n"));
            strDataTable = (strDataTable + "EDIT" + "\r\n");
            //strDataTable = (strDataTable + ("  " + ("<font SIZE='1' FACE='Arial' COLOR='navy'>" + ("EDIT" + ("</font>" + "\r\n")))));
            strDataTable = (strDataTable + ("</a>" + "\r\n"));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Change Column name as required
            //May have to check Loaded_Machine for NULL, if it is not mandatory.
            //--------------------------------------------------------------------------------------------------------------------------------------------
            if (objDR["Array_Name"] == null
                   || (Convert.ToString(objDR["Array_Name"]).Length == 0))
            {
                strStartDate = "&nbsp;";
            }
            else
            {
                strStartDate = Convert.ToString(objDR["Array_Name"]);
            }

            //strDataTable = (strDataTable + ("<td ALIGN='left' WIDTH='160px'" + "\r\n"));
            //strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
            //strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            //strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            //strDataTable = (strDataTable + (" FONT-SIZE: 11px;" + "\r\n"));
            //strDataTable = (strDataTable + (" FONT-FAMILY: Arial;" + "\r\n"));
            //strDataTable = (strDataTable + (" COLOR: black;" + "\r\n"));
            //strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
            //strDataTable = (strDataTable + "" + ("<b><a style='text-decoration:none;color:black' href='JavaScript: Detail1(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            //strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            //strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex=\'-1\' title=\'Array Name\' " + (" >" + "\r\n")))))))))));
            //strDataTable = (strDataTable + (strStartDate + "\r\n"));
            //strDataTable = (strDataTable + ("</a></b>" + "\r\n"));
            //strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //OR if want to edit field on the fly
            //---------------------------------------------------------------------------
            strsize2 = "12";
            strDataTable = (strDataTable + ("<td ALIGN='left' WIDTH='155px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
            // Note:- Change id=aa if other checkboxes or fields updated on the fly
            strDataTable = (strDataTable + (" <INPUT id=aa" + (intcounter + ("c7 type=\'text\'  " + "\r\n"))));
            strDataTable = (strDataTable + (" style='WIDTH: 142px;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-WEIGHT: bold;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-FAMILY: arial;" + "\r\n"));
            strDataTable = (strDataTable + (" COLOR: black;" + "\r\n"));
            strDataTable = (strDataTable + (" TEXT-ALIGN: left;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-SIZE: " + (strsize2 + ("px ' " + "\r\n"))));
            strDataTable = (strDataTable + ("onclick='Detail12(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (");\' " + "\r\n")))))))));
            strDataTable = (strDataTable + ("onchange='updatefield(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (");\' " + (" value= " + ('"' + (objDR["Array_Name"] + ('"' + (" >" + "\r\n"))))))))))))));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Change Column name as required
            //May have to check Loaded_Machine for NULL, if it is not mandatory.
            //--------------------------------------------------------------------------------------------------------------------------------------------
            if (objDR["Loaded_Machine"] == null
                   || (Convert.ToString(objDR["Loaded_Machine"]).Length == 0))
            {
                strStartDate = "&nbsp;";
            }
            else
            {
                strStartDate = Convert.ToString(objDR["Loaded_Machine"]);
            }

            strDataTable = (strDataTable + ("<td ALIGN='left' WIDTH='150px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-SIZE: 11px;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-FAMILY: Arial;" + "\r\n"));
            strDataTable = (strDataTable + (" COLOR: black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
            strDataTable = (strDataTable + "" + ("<a style='text-decoration:none;color:black' href='JavaScript: Detail1(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex=\'-1\' title=\'Array Name\' " + (" >" + "\r\n")))))))))));
            //strDataTable = (strDataTable + ("  <font size='2' face='Arial' color='black'>" + "\r\n"));
            strDataTable = (strDataTable + (strStartDate + "\r\n"));
            //strDataTable = (strDataTable + ("</font>" + "\r\n"));
            strDataTable = (strDataTable + ("</a>" + "\r\n"));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Change Column name as required
            //May have to check Start Date for NULL, if it is not mandatory.
            //--------------------------------------------------------------------------------------------------------------------------------------------
            if (objDR["Start_Date"] == null
                             || (Convert.ToString(objDR["Start_Date"]).Length == 0))
            {
                strStartDate = "&nbsp;";
            }
            else
            {
                ws_conv_datestring = Convert.ToString(objDR["Start_Date"]);
                ws_conv_date = DateTime.Parse(ws_conv_datestring);
                strStartDate = dateconvit(ws_conv_date);
            }

            strDataTable = (strDataTable + ("<td ALIGN='left' WIDTH='90px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-SIZE: 11px;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-FAMILY: Arial;" + "\r\n"));
            strDataTable = (strDataTable + (" COLOR: black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
            
            //strDataTable = (strDataTable + "" + ("<a style='text-decoration:none;color:black' href='JavaScript: Detail1(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            //strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            //strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex=\'-1\' title=\'Array Name\' " + (" >" + "\r\n")))))))))));
            //strDataTable = (strDataTable + (strStartDate + "\r\n"));
            //strDataTable = (strDataTable + ("</a>" + "\r\n"));

            // next 6 lines are for updating date on the fly Option
            strdatename = "Start_Date";
            strDataTable = (strDataTable + ("<a href='JavaScript: calendarpopup(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (strdatename + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex='-1' title='Title' " + (" >" + "\r\n")))))))))));
            strDataTable = (strDataTable + (strStartDate + "\r\n"));
            strDataTable = (strDataTable + ("</a>" + "\r\n"));
            
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


            
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Change Column name as required
            //May have to check End Date for NULL, if it is not mandatory.
            //--------------------------------------------------------------------------------------------------------------------------------------------
            if (objDR["End_Date"] == null
                             || (Convert.ToString(objDR["End_Date"]).Length == 0))
            {
                strStartDate = "&nbsp;";
            }
            else
            {
                ws_conv_datestring = Convert.ToString(objDR["End_Date"]);
                ws_conv_date = DateTime.Parse(ws_conv_datestring);
                strStartDate = dateconvit(ws_conv_date);
            }

            strDataTable = (strDataTable + ("<td ALIGN='left' WIDTH='90px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-SIZE: 11px;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-FAMILY: Arial;" + "\r\n"));
            strDataTable = (strDataTable + (" COLOR: black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
            
            //strDataTable = (strDataTable + "" + ("<a style='text-decoration:none;color:black' href='JavaScript: Detail1(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            //strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            //strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex=\'-1\' title=\'Array Name\' " + (" >" + "\r\n")))))))))));
            //strDataTable = (strDataTable + (strStartDate + "\r\n"));
            //strDataTable = (strDataTable + ("</a>" + "\r\n"));

            // next 6 lines are for updating date on the fly Option
            strdatename = "End_Date";
            strDataTable = (strDataTable + ("<a href='JavaScript: calendarpopup(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (strdatename + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")\' " + (" tabIndex='-1' title='Title' " + (" >" + "\r\n")))))))))));
            strDataTable = (strDataTable + (strStartDate + "\r\n"));
            strDataTable = (strDataTable + ("</a>" + "\r\n"));

            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //NOTE:- OPTIONAL - MUST TAKE OUT IF NOT USING A CheckBox in List (Also must adjust Table width size again)
            //CheckBox Column, PK_ID may have to change
            //-----------------------------------------------------
            if (objDR["Complete_Flag"] == null)
            {
                strFlag = "";
            }
            else
            {
                strBoolean = Convert.ToString(objDR["COMPLETE_FLAG"]);
                if (strBoolean == "True")
                {
                    strFlag = "CHECKED";
                }
                else
                {
                    strFlag = "";
                }
            }

            strDataTable = (strDataTable + ("<td ALIGN=center WIDTH=110px" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" FONT-SIZE: 10px;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid silver'>" + "\r\n"));
            strDataTable = (strDataTable + (" <INPUT id=r" + (intcounter + ("c7 type='checkbox'  " + "\r\n"))));
            strDataTable = (strDataTable + ("onclick='chkclick(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (");' " + (" value=\'Yes\' " + (strFlag + (" >" + "\r\n"))))))))))));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


            
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //NOTE:- OPTIONAL - MUST TAKE OUT IF NOT USING A DELETE Button in List (Also must adjust Table width size again)
            //DELETE Column, PK_ID may have to change, Array_Name may have to change, so as to show what is being Deleted
            //--------------------------------------------------------------------------------------------------------------------------------------------
            strDataTable = (strDataTable + ("<td ALIGN=center WIDTH=37px" + "\r\n"));
            strDataTable = (strDataTable + (" style='BORDER-TOP: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid silver;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid white;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid silver'>" + "\r\n"));
            strDataTable = (strDataTable + ("<a href='JavaScript: DelClick(" + ('"' + (objDR["PK_ID"] + ('"' + ("," + ('"' + (intcounter + ('"' + ",")))))))));
            strDataTable = (strDataTable + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ","))))))));
            strDataTable = (strDataTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + ("," + ('"' + (objDR["Array_Name"] + ('"' + (")' " + (" tabIndex='-1' title='Title' " + (" >" + "\r\n")))))))))))))));
            //strDataTable = (strDataTable + (" <img SRC=\'./images/DEL_04.gif\' ALT=\'Delete Array\' TITLE=\'Delete Array\' WIDTH=33px HEIGHT=21px border" +"=\'0\'> " + "\r\n"));
            strDataTable = (strDataTable + ("<font size=1 face='Arial' color='red'>" + ("Del" + ("</font>" + "\r\n"))));
            strDataTable = (strDataTable + ("</a>" + "\r\n"));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //KEY Column, PK_ID may have to change, must make visibility = hidden 
            // NOTE:-  Can change hidden  -->   visible, for displaying variables below
            //-----------------------------------------------------------------------------------
            strDataTable = (strDataTable + ("<td WIDTH='245px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='display: none;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-TOP: 1px solid black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid black'>" + "\r\n"));
            strDataTable = (strDataTable + (" <font size='1'>" + "\r\n"));
            strDataTable = (strDataTable + (objDR["PK_ID"] + "\r\n"));
            strDataTable = (strDataTable + ("</font>" + "\r\n"));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

            strDataTable = (strDataTable + ("<td id='row6'  WIDTH='10px'" + "\r\n"));
            strDataTable = (strDataTable + (" style='display: none;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-TOP: 1px solid black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-BOTTOM: 1px solid black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-LEFT: 1px solid black;" + "\r\n"));
            strDataTable = (strDataTable + (" BORDER-RIGHT: 1px solid black'>" + "\r\n"));
            strDataTable = (strDataTable + (" <font size='1'>" + "\r\n"));
            strDataTable = (strDataTable + (intcounter + "\r\n"));
            strDataTable = (strDataTable + ("</font>" + "\r\n"));
            strDataTable = (strDataTable + ("</td>" + "\r\n"));

            //END of ROW
            strDataTable = (strDataTable + ("</tr>" + "\r\n"));


            if (intcounter == 0)
            {
                //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                //PK_ID may have to change
                //--------------------------------
                //STORE PK_ID HIDDEN value ready to display
                strDispPKID = DispPKIDInfo(Convert.ToString(objDR["PK_ID"]));
                //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            }


            intcounter = intcounter + 1;

            // if (intsubcounter == intPageSize)      //stop reading if got page full  
            // {
            //     break;
            // }

        }      //end while

        objDR.Close();
        objConn.Close();

        strDataTable = (strDataTable + ("</table>" + "\r\n"));


    }




    // --------------------------------------------------------------------------------------------------------------------------------------------------------------
    private void GetHeaderTable()
    {
        //  This must match the Table from the above Function GetPageOfRecords()
        //  Can be modified to suit
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------
        //response.write(("in GetHeaderTable " + "<br>\""));
        strHeaderTable = "";
        strHeaderTable = (strHeaderTable + ("<table id='myHeader' border='0' bgcolor='white' bordercolor='gray' cellspacing='0' cellpadding='0' width='682" + "px'>" + "\r\n"));
        // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        strHeaderTable = (strHeaderTable + ("<tr>" + "\r\n"));

        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //NOTE:- OPTIONAL - MUST TAKE OUT IF NOT USING A ADD Button in List (Also must adjust Table width size again)
        //----------------------------------------------------------------------------------------------------------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN='center' WIDTH='47px' HEIGHT='24px' BGCOLOR='white' BORDERCOLOR='gray' " + "\r\n"));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 0px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 0px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 0px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 0px solid gray'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("<a href='JavaScript: Add1(" + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ",")))))))));
        strHeaderTable = (strHeaderTable + ('"' + (strSortField + ('"' + ("," + ('"' + (intPageSize + ('"' + (")' " + (" tabIndex='-1' title='Add' " + (" >" + "\r\n")))))))))));
        strHeaderTable = (strHeaderTable + (" " + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" ADD " + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" <img SRC=\'./images/ADD_04.gif\' ALT=\'Add Array\' WIDTH=45px HEIGHT=25px border=\'0\'> " + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</a>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Column acting as a SORT, Array_Name, PK_ID may have to change to suit Sort Index
        //---------------------------------------------------------------------------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN='left' WIDTH='160px' id = " + ('"' + ("Array_Name asc, PK_ID" + ('"' + (" BGCOLOR='#006699' BORDERCOLOR='gray' " + "\r\n"))))));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-SIZE: 12px;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" COLOR: white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid gray'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + "" + ("<a style='text-decoration:underline;color:white' href='JavaScript: Sort1(" + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ",")))))))));
        strHeaderTable = (strHeaderTable + ('"' + ("Array_Name asc, PK_ID" + ('"' + ("," + ('"' + (intPageSize + ('"' + (")' " + (" tabIndex='-1' title='Array' " + (" >" + "\r\n")))))))))));
        strHeaderTable = (strHeaderTable + (" Array Name" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</a>" + "\r\n"));

        strHeaderTable = (strHeaderTable + ("<span id='Array_Name asc, PK_IDasc' style='display:none;padding:4px;color:yellow'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("asc" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</span>" + "\r\n"));

        strHeaderTable = (strHeaderTable + ("<span id='Array_Name asc, PK_IDdesc' style='display:none;padding:4px;color:yellow'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("desc" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</span>" + "\r\n"));
        
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Column acting as a SORT, Loaded_Machine, PK_ID may have to change to suit Sort Index
        //---------------------------------------------------------------------------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN='left' WIDTH='150px' id = " + ('"' + ("Loaded_Machine asc, PK_ID" + ('"' + (" BGCOLOR='#006699' BORDERCOLOR='gray' " + "\r\n"))))));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-SIZE: 12px;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" COLOR: white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid gray'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + "" + ("<a style='text-decoration:underline;color:white' href='JavaScript: Sort1(" + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ",")))))))));
        strHeaderTable = (strHeaderTable + ('"' + ("Loaded_Machine asc, PK_ID" + ('"' + ("," + ('"' + (intPageSize + ('"' + (")' " + (" tabIndex='-1' title='Machine' " + (" >" + "\r\n")))))))))));
        strHeaderTable = (strHeaderTable + ("Machine" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</a>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Column acting as a SORT, START_DATE desc, PK_ID may have to change to suit Sort Index
        //--------------------------------------------------------------------------------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN='left' WIDTH='90px' id = " + ('"' + ("Start_Date asc, PK_ID" + ('"' + (" BGCOLOR='#006699' BORDERCOLOR='gray' " + "\r\n"))))));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-SIZE: 12px;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" COLOR: white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid gray'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + "" + ("<a style='text-decoration:underline;color:white' href='JavaScript: Sort1(" + ('"' + (intCurrentPage + ('"' + ("," + ('"' + (intSkipCount + ('"' + ",")))))))));
        strHeaderTable = (strHeaderTable + ('"' + ("Start_Date asc, PK_ID" + ('"' + ("," + ('"' + (intPageSize + ('"' + (")' " + (" tabIndex='-1' title='Machine' " + (" >" + "\r\n")))))))))));
        strHeaderTable = (strHeaderTable + ("Start Date" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</a>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Change Column name as required
        //----------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN='left' WIDTH='90px' BGCOLOR='#006699' BORDERCOLOR='gray' " + "\r\n"));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-SIZE: 12px;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" COLOR: white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid gray'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("End Date" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //Change Column name as required
        //----------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN='center' WIDTH='110px' BGCOLOR='#006699' BORDERCOLOR='gray' " + "\r\n"));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid gray;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-SIZE: 12px;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" FONT-FAMILY: Arial;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" COLOR: white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid gray'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("Complete Flag" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        //NOTE:- OPTIONAL - MUST TAKE OUT IF NOT USING A DELETE Button in List (Also must adjust Table width size again)
        //ALSO, adjust this Blank column size to suit, if say the Add button is not used (ie 37 + 57 = 94) OR nothing at all.
        //---------------------------------------------------------------------------------------------------------------------------------------------
        strHeaderTable = (strHeaderTable + ("<th ALIGN=left WIDTH=37px BGCOLOR=white BORDERCOLOR=white " + "\r\n"));
        strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid white;" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("<font size=2 face='Arial' COLOR='white'>" + "\r\n"));
        strHeaderTable = (strHeaderTable + (" " + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</font>" + "\r\n"));
        strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

        
        
        //strHeaderTable = (strHeaderTable + ("<th ALIGN='left' WIDTH='245px' BGCOLOR='white' BORDERCOLOR='white' " + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid white;" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid white;" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
        //strHeaderTable = (strHeaderTable + ("<font size='1' face='Arial' COLOR='white'>" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" " + "\r\n"));
        //strHeaderTable = (strHeaderTable + ("</font>" + "\r\n"));
        //strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));
        
        //strHeaderTable = (strHeaderTable + ("<th ALIGN='left' WIDTH='10px' BGCOLOR='white' BORDERCOLOR='white' " + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" style='BORDER-TOP: 1px solid white;" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" BORDER-BOTTOM: 1px solid white;" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" BORDER-LEFT: 1px solid white;" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" BORDER-RIGHT: 1px solid white'>" + "\r\n"));
        //strHeaderTable = (strHeaderTable + ("<font size='1' face='Arial' COLOR='white'>" + "\r\n"));
        //strHeaderTable = (strHeaderTable + (" " + "\r\n"));
        //strHeaderTable = (strHeaderTable + ("</font>" + "\r\n"));
        //strHeaderTable = (strHeaderTable + ("</th>" + "\r\n"));

        strHeaderTable = (strHeaderTable + ("</tr>" + "\r\n"));

        strHeaderTable = (strHeaderTable + ("</table>" + "\r\n"));

    }



    string dateconvit(DateTime wsDate)
    {
        // convert create_date to yyyymmdd and dd/mm/yyyy
        string ws_dayy;
        string ws_yearr;
        string ws_monthh;
        string ws_dayit;
        string wzz_date;
        string ws_result_dated;
        DateTime wss_date;
        //wzz_date = wsDate.ToString("d");

        ws_result_dated = wsDate.ToString("d");

        // Response.Write("This Page is  " + wsDate.ToString() + "<br>");

        //if ((wsDate == null)) {]
        if ((ws_result_dated == null))
        {
            return " ";
            //dateconvit = " ";
        }
        else
        {
            //wss_date = wsDate;
            ws_dayy = Convert.ToString(wsDate.Day);
            //ws_dayy = wsDate.ToString();

            //ws_dayy = datepart("d", wsDate);
            ws_dayit = ws_dayy;
            // response.write("lendate is" & ws_dayit.Length)
            if ((ws_dayit.Length == 1))
            {
                ws_dayy = (0 + ws_dayy);
            }
            ws_monthh = Convert.ToString(wsDate.Month);
            //ws_monthh = DatePart("m", wsDate);
            if ((ws_monthh.Length == 1))
            {
                ws_monthh = (0 + ws_monthh);
            }
            ws_yearr = Convert.ToString(wsDate.Year);
            //ws_yearr = DatePart("yyyy", wsDate);

            return (ws_dayy + ("/"
                        + (ws_monthh + ("/" + ws_yearr))));


        }
    }


</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    
    </form>
</body>
</html>
